Data bit shifting and rotation are common operations by which bits of a data word are shifted into lower order bit positions (shift right) or into higher order bit positions (shift left). On an integrated circuit, real estate is generally a scarce commodity as more and more functions are to be provided within a limited area. Therefore, it is desirable to have a universal shifter unit capable of handling both the shift and rotate operations, which can be implemented in an efficient manner that reduces the number of logic required.
Conventional circuits for performing left and right shifting of bits (the bits comprising a data word) and rotation have been implemented. However, such shifting circuits include two separate circuit branches: one for shifting the bits to the left; the other for shifting the bits to the right.
U.S. Pat. No. 6,304,956 entitled ‘Using two barrel shifters to implement shift, rotate, rotate with carry, and shift double as specified by the X86 architecture’ discloses a shifter unit having three major portions: a right shifter, a left shifter and control logic. For shifting operations, only one of the two shifters is used, while rotation functions require both left and right shifters.
The results of the two shifters are then provided to a merging logic for logic operations. Depending on the instruction type, the merging logic performs different logic operations on the two results. For example, in some instructions (rotation), the two results are ORed together. In some other instructions (shifting), only one result is needed from one of the two shifters, and the result of the other shifter is ignored. The merging logic outputs the desired results as an output.
For rotation, both of the two shifters are provided with the source operand. Then, the first shifter shifts the source operand by a first number, where the first number is the count operand as defined in the instruction. The second shifter shifts the source operand by a second number, where the first number in addition with the second number is equal to the number of bits of the source operand. Due to the two branches, each using a barrel shifter, the area consumed by this technique is very large.
The U.S. Pat. No. 5,978,822 entitled “Circuit for rotating, left shifting, or right shifting bits” uses a single branch of a shifter unit which is capable of performing shifting and rotation operations. The circuit includes a set of series connected multiplexer stages, and circuitry for selectively inverting the order of the bits of the word input to and the word output from the set of multiplexer stages. Each of the multiplexer stages shifts the bits of the word it receives either by zero places (in response to a first condition of a control signal), or by a positive number of places (in response to a second condition of the control signal).
To execute a left shift, the circuitry for selectively inverting the input to the multiplexer stages does not invert the order of the bits of the input word. To execute a right shift, the circuitry for selectively inverting the input to the multiplexer stages inverts the order of the bits of the input word.
To enable the circuit to perform rotations (by a selectable number of bits to the left or right) of bits of the input word, a first one of the multiplexer stages includes bit selection circuitry for asserting appropriate bits needed for executing any such rotation to multiplexing circuitry in that multiplexer stage.
But for a circuit of input digital data word containing 2n bits, shifting can be done from 0 to n−1 places, while rotation can be done only up to (n/2)−1 places. Thus it can rotate the input bits up to some places only of an input word (by two or more bits to the left or right) during a single cycle, by duplicating the input word to form an extended word, shifting bits of the extended word, and selecting a subset of the shifted bits of the extended word.
U.S. Pat. No. 5,844,825 entitled “Bidirectional Shifter Circuit” comprises one shifter unit and two bit reversing circuits: one at the input of the shifter unit and one at the output of the shifter unit. This technique can handle two operations and these two operations are based on the shifter unit, left or right. Further it can handle left rotation and right rotation.
In this technique, the bidirectional shifter has 3 components: a first bit reversing circuit, a single direction shifter circuit and a second bit reversing circuit. The first bit reversing circuit receives an input data word. In response to choosing a first shift direction, the first bit reversing circuit outputs the data word with the bits in their original order. In response to choosing the second shift direction, the first bit-reversing circuit outputs the data word with the bits in reverse order. A single-direction shifter circuit is provided which receives the data word outputted by the first bit-reversing circuit and shifts the received data word the chosen number of bit positions in the first direction. A second bit-reversing circuit is provided which receives the shifted data word and which, in response to choosing the first shift direction, outputs the data word with the bits in the same order as received and, in response to choosing the second shift direction, outputs the data word with the bits in reverse order.
If the shifter unit is a left cyclic shifter, then the circuit can handle only left and right cyclic shifting i.e. ROL and ROR. This technique can handle only two types of the operation based on the shifter unit. Thus said circuit does not do all the expected operations.